package com.insigma.business.qrcode.soldier.dto;

import com.google.common.base.Strings;
import com.insigma.business.qrcode.common.vo.DescEnum;

import java.util.LinkedHashMap;
import java.util.Map;


public enum GenderEnum implements DescEnum {

    
    SECRET("保密"),

    
    MALE("男"),

    
    FEMALE("女");

    
    private String desc;

    GenderEnum(String desc) {
        this.desc = desc;
    }

    
    public static GenderEnum getByEnumName(final String enumName) {
        for (GenderEnum element : values()) {
            if (element.name().equals(enumName)) {
                return element;
            }
        }
        return null;
    }

    public static String getDescByEnumName(final String enumName) {
        GenderEnum byEnumName = getByEnumName(enumName);
        if (byEnumName != null) {
            byEnumName.getDesc();
        }
        return null;
    }

    @Override
    public String getDesc() {
        return this.desc;
    }

    
    public static Map<String,String> getName2TitleMap(){
        Map<String,String> name2TitleMap = new LinkedHashMap<>();
        for (GenderEnum element : values()) {
            name2TitleMap.put(element.name(),element.desc);
        }
        return name2TitleMap;
    }

    public static String getCodeByValue(String input) {
        if (Strings.isNullOrEmpty(input)) {
            return null;
        }
        if (input.contains("男")) {
            return "MALE";
        }
        if (input.contains("女")) {
            return "FEMALE";
        }
        return null;
    }
}
